package com.adwin.addcoin.repository.api

import com.adwin.addcoin.BuildConfig
import com.adwin.addcoin.repository.bean.AppDispositionBean
import com.adwin.addcoin.repository.bean.CheckInBean
import com.adwin.addcoin.repository.bean.CheckInResponse
import com.adwin.addcoin.repository.bean.InviteDetailsBean
import com.adwin.addcoin.repository.bean.InviteRewardsBean
import com.adwin.addcoin.repository.bean.LoginBean
import com.adwin.addcoin.repository.bean.TaskDetailBean
import com.adwin.addcoin.repository.bean.TaskResponseBean
import com.adwin.addcoin.repository.bean.TaskStageResults
import com.adwin.addcoin.repository.bean.UserCoinBean
import com.adwin.addcoin.repository.bean.UserInfoBean
import com.adwin.addcoin.repository.net.BaseResponse
import com.google.gson.JsonArray
import com.google.gson.JsonObject
import io.reactivex.rxjava3.core.Observable
import okhttp3.RequestBody
import okhttp3.ResponseBody
import org.json.JSONArray
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query


interface TestApi {

    /**
     *  source 来源 google facebook
     *  oauth2Token 三方授权令牌
     *  id 设备id （gaid,afid）
     *  {"code":401,"message":"authToken is expired"}  token 失效了
     *  country 国家
     */
    @POST("user/oauth2/login/")
    fun login(@Body body: RequestBody): Observable<Response<BaseResponse<LoginBean>>>

    /**
     * 获取用户当前签到信息
     */
    @GET("user/checkin/details")
    fun getCheckInMessage():Observable<Response<BaseResponse<CheckInBean>>>

    /**
     * 用户签到
     */
    @GET("user/checkin")
    fun checkIn():Observable<Response<BaseResponse<CheckInResponse>>>

    /**
     * 用户退出登录
     */
    @GET("user/logout")
    fun logOut():Observable<Response<BaseResponse<Boolean>>>

    /**
     * 获取用户信息
     */
    @GET("user/profile")
    fun getUserInfo():Observable<Response<BaseResponse<UserInfoBean>>>

    /**
     * 获取邀请详情
     */
    @GET("user/invite/details")
    fun getInviteDetails():Observable<Response<BaseResponse<InviteDetailsBean>>>

    /**
     * 查询邀请用户奖励
     */
    @GET("user/invite/rewards")
    fun getInviteRewards():Observable<Response<BaseResponse<InviteRewardsBean>>>

    /**
     * 填写邀请码
     */
    @PUT("user/invite/{code}")
    fun editInviteCode(@Path("code") code:String):Observable<Response<BaseResponse<Any>>>

    /**
     * 日志上报
     */
    @POST("${BuildConfig.ReportUrl}en/tba/sync_data")
    fun syncData(@Body test:RequestBody):Observable<String>



    /**
     * Cloak接入  返回的是html协议不能按json格式解析
     */
    @GET("https://target.adwin-win.com/pine/freehand/atomic")
    fun checkAppCloak(@Query("sylow") distinct_id:String,@Query("rudyard") client_ts:String,
                      @Query("adherent") device_model:String,@Query("insolent") bundle_id:String,
                      @Query("deluge") os_version:String,@Query("thuban") gaid:String,
                      @Query("ridge") android_id:String,@Query("wastage") os:String,
                      @Query("stodgy") app_version:String,@Query("gesture") app_id:String):Observable<ResponseBody>

    /**
     * 获取活动列表
     */
    @POST("activity/page")
    fun getCoinActivityList(@Body test: RequestBody):Observable<Response<BaseResponse<TaskResponseBean>>>

    /**
     * 获取活动详情
     */
    @GET("activity/detail")
    fun getActivityDetail(@Query("activityId") activityId:Long):Observable<Response<BaseResponse<TaskDetailBean>>>


    /**
     * 获取任务列表
     */
    @POST("mission/page")
    fun getTaskList(@Body test: RequestBody):Observable<Response<BaseResponse<TaskResponseBean>>>

    /**
     * 获取任务详情
     */
    @GET("mission/detail")
    fun getTaskDetail(@Query("orderId") missionId:Long):Observable<Response<BaseResponse<TaskDetailBean>>>

    /**
     * 用户接取任务
     */
    @POST("mission/start")
    fun startTask(@Body test: RequestBody):Observable<Response<BaseResponse<Boolean>>>

    /**
     * 查询任务步骤状态
     */
    @POST("mission/step/status")
    fun queryTaskStatus(@Body test: RequestBody):Observable<Response<BaseResponse<TaskStageResults>>>

    /**
     * 查询当前用户金币详情
     */
    @GET("user/coin/detail")
    fun queryUserCoinDetail():Observable<Response<BaseResponse<UserCoinBean>>>

    /**
     * 获取H5页面链接
     */
    @GET("config/h5/page/links")
    fun getAppDisposition():Observable<Response<BaseResponse<AppDispositionBean>>>

    /**
     * 获取当前任务
     */
    @GET("https://{taskUrl}")
    fun senTask(@Path("taskUrl") taskUrl:String):Observable<Response<BaseResponse<Any>>>

    /**
     * 提交用户反馈
     */
    @POST("user/feedback")
    fun feedback(@Body test: RequestBody):Observable<Response<BaseResponse<Any>>>

    /**
     * 刷新token
     */
    @POST("user/refresh")
    fun refreshToken(@Body test: RequestBody):Observable<Response<BaseResponse<LoginBean>>>

    /**
     * 游客登录
     */
    @POST("user/oauth2/guest/login")
    fun guestLogin():Observable<Response<BaseResponse<LoginBean>>>

    /**
     * 删除用户
     */
    @DELETE("user/delete")
    fun userDelete():Observable<Response<BaseResponse<Boolean>>>
}